package com.ujoku.view.domain.admin;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.labillusion.core.util.jsonFormat.SimpleDoubleSerializer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Greg.Chen on 2015/3/3.
 */
public class MyListMemberView {
    public MyListMemberView(){
        list = new ArrayList<>();
    }

    private List<MyListMemberItemView> list;

    public List<MyListMemberItemView> getList() {
        return list;
    }

    public void setList(List<MyListMemberItemView> list) {
        this.list = list;
    }

    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double total;

    public Double getTotal() {
        if(this.getList() != null && this.getList().size() > 0)
            return this.getList().stream().mapToDouble(i->i.getPrice() * i.getQty()).sum();

        return null;
    }


}

